/**
 * 模拟数据生成器 - 用于测试和演示
 */

// 模拟农机设备数据
export const mockDevices = [
  {
    id: 1,
    deviceName: "拖拉机01",
    deviceType: "TRACTOR",
    status: "WORKING",
    currentPosition: {
      x: 116.4074, // 经度
      y: 39.9042   // 纬度
    },
    lastUpdateTime: new Date().toISOString(),
    createdTime: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString()
  },
  {
    id: 2,
    deviceName: "收割机01",
    deviceType: "HARVESTER", 
    status: "IDLE",
    currentPosition: {
      x: 116.4174,
      y: 39.9142
    },
    lastUpdateTime: new Date().toISOString(),
    createdTime: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString()
  },
  {
    id: 3,
    deviceName: "播种机01",
    deviceType: "SEEDER",
    status: "OFFLINE", 
    currentPosition: {
      x: 116.3974,
      y: 39.8942
    },
    lastUpdateTime: new Date(Date.now() - 2 * 60 * 60 * 1000).toISOString(),
    createdTime: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString()
  }
];

// 模拟地块数据
export const mockParcels = [
  {
    id: 1,
    parcelName: "北地块",
    area: 100000,
    soilType: "黑土",
    parcelBoundary: {
      coordinates: [[
        { x: 116.40, y: 39.90 },
        { x: 116.41, y: 39.90 },
        { x: 116.41, y: 39.91 },
        { x: 116.40, y: 39.91 },
        { x: 116.40, y: 39.90 }
      ]]
    },
    createdTime: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString()
  },
  {
    id: 2,
    parcelName: "南地块", 
    area: 80000,
    soilType: "黄土",
    parcelBoundary: {
      coordinates: [[
        { x: 116.42, y: 39.89 },
        { x: 116.43, y: 39.89 },
        { x: 116.43, y: 39.90 },
        { x: 116.42, y: 39.90 },
        { x: 116.42, y: 39.89 }
      ]]
    },
    createdTime: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString()
  },
  {
    id: 3,
    parcelName: "东地块",
    area: 120000,
    soilType: "沙土",
    parcelBoundary: {
      coordinates: [[
        { x: 116.44, y: 39.91 },
        { x: 116.45, y: 39.91 },
        { x: 116.45, y: 39.92 },
        { x: 116.44, y: 39.92 },
        { x: 116.44, y: 39.91 }
      ]]
    },
    createdTime: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString()
  }
];

// 模拟轨迹数据
export const mockPaths = [
  {
    id: 1,
    deviceId: 1,
    deviceName: "拖拉机01",
    pathName: "作业路径1",
    pathPoints: [
      { longitude: 116.4074, latitude: 39.9042 },
      { longitude: 116.4084, latitude: 39.9052 },
      { longitude: 116.4094, latitude: 39.9062 },
      { longitude: 116.4104, latitude: 39.9072 },
      { longitude: 116.4114, latitude: 39.9082 }
    ],
    startTime: new Date(Date.now() - 4 * 60 * 60 * 1000).toISOString(),
    endTime: new Date(Date.now() - 2 * 60 * 60 * 1000).toISOString(),
    totalDistance: 1250.5,
    createdTime: new Date().toISOString()
  },
  {
    id: 2,
    deviceId: 2,
    deviceName: "收割机01", 
    pathName: "收割路径1",
    pathPoints: [
      { longitude: 116.4174, latitude: 39.9142 },
      { longitude: 116.4184, latitude: 39.9152 },
      { longitude: 116.4194, latitude: 39.9162 },
      { longitude: 116.4204, latitude: 39.9172 }
    ],
    startTime: new Date(Date.now() - 6 * 60 * 60 * 1000).toISOString(),
    endTime: new Date(Date.now() - 3 * 60 * 60 * 1000).toISOString(),
    totalDistance: 980.3,
    createdTime: new Date().toISOString()
  }
];

/**
 * 检查是否使用模拟数据
 */
export const shouldUseMockData = () => {
  // 可以通过环境变量或其他方式控制
  return !navigator.onLine || window.location.search.includes('mock=true');
};